package com.hzdl.car.sqlprovider;

import com.hzdl.car.util.Common;
import com.hzdl.car.vo.UserVo;
import org.apache.ibatis.jdbc.SQL;

public class UserSqlProvider {
    public String findUser(UserVo userVo){
        return new SQL(){{
            SELECT("*");
            FROM("sys_user");
            if(!Common.isEmpty(userVo.getIdentity())){
                WHERE("identity like concat('%',#{identity},'%')");
            }
            if(!Common.isEmpty(userVo.getLoginName())){
                WHERE("loginName like concat('%',#{loginName},'%')");
            }
            if(!Common.isEmpty(userVo.getRealName())){
                WHERE("realName like concat('%',#{realName},'%')");
            }
            if(!Common.isEmpty(userVo.getAddress())){
                WHERE("address like concat('%',#{address},'%')");
            }
            if(!Common.isEmpty(userVo.getPhone())){
                WHERE("phone like concat('%',#{phone},'%')");
            }
            if(!Common.isEmpty(userVo.getPosition())){
                WHERE("position like concat('%',#{position},'%')");
            }

        }}.toString();
    }
}
